
#ifndef GRAVBODY_H
#define GRAVBODY_H

// For critical section / semaphore usage
#include <windows.h>
#include <winnt.h>

#include <iostream>
#include <list>
#include "vec3f.h"
#include "Geosphere.h"

using namespace std;

class GravBody {

	public:
		void init(vec3f loc, vec3f vel, float rad, float mass);
		void updateWithForce(vec3f f, float timeScale);
		void updateHistory(float timePass);
		void alterTerrain();

		const vec3f* getLoc();
		const vec3f* getVel();
		const float getRad();
		const float getMass();
		const float getMassSqr();
		const float getInvMassSqr();
		const int getMaxDetail();
		const list<vec3f>* getHistory();
		Geosphere* getGeosphere();
		vec3f getGfxLoc();

		void getHistoryAccess(bool enter);

	private:
		Geosphere* gGeo;
		vec3f vLoc;
		vec3f vVel;
		float fRad;
		float fMass;
		float fMassSqr;
		float fInvMassSqr;
		list<vec3f> history;
		float historyTime;
		int maxDetail;
		
		CRITICAL_SECTION historyCS;

};

#endif